<template>
	<div class="tpl33-header"
   :style="tplItemData.modulePadding || tplItemData.modulePadding ==0?'padding-top:'+tplItemData.modulePadding+'px;padding-bottom:'+tplItemData.modulePadding+'px;':'padding-top:5px;padding-bottom:5px;'">
    <!-- 折叠轮播 -->
    <div ref="getHeight" class="imgAdv-box">
      <wx-swiper class="my-swipe" :style="`height: ${imgadvWxH}`" :circular="true" indicator-color="#ebedf0" indicator-active-color="#FE5000" :autoplay="autoplay" :indicator-dots="showIndicators">
        <wx-swiper-item v-for="(item,index) in tplItemData.dataset" :key="index">
          <h4 class="imgAdv_title" v-if="tplItemData.isTitle == 1">
            {{item.showtitle}}
            <span class="subTitle">{{item.subtitle}}</span>
          </h4>
          <a @click="openLink(item.link)">
            <img :src="item.pic" alt="" @load="onImageLoad($event)"/>
          </a>
        </wx-swiper-item>
      </wx-swiper>
      <!-- <van-swipe v-else class="my-swipe" :autoplay="3000" indicator-color="#FE5000">
        <van-swipe-item v-for="(item,index) in tplItemData.dataset" :key="index">
          <a :href="item.link">
            <img :src="item.pic" alt="" />
          </a>
        </van-swipe-item>
      </van-swipe> -->
    </div>
  </div>
</template>

<script>
  /**
   * @Author: yqe@360shop.cn
   * @Date: 2020年07月08日15:11:21
   * @Last Modified by: yqe@360shop.cn
   * @Last Modified time: 2020年07月08日15:11:21
   */
import Vue from 'vue'
import { openPage } from '@/utils/utils'
// import { Swipe, SwipeItem } from 'vant'
// Vue.use(Swipe)
// Vue.use(SwipeItem)
export default Vue.extend({
    name: 'index',
    data() {
      return {
        showIndicators: true,
        autoplay: true,
        imgadvWxH: 0
      }
    },
    props: {
      tplItemData: {
        type: Object // 传入参数的类型
      }
    },
    methods: {
      // TODO 小程序跳转
      openLink(link) {
        openPage(link)
      },
      // TODO 小程序swiper获取图片高度
      onImageLoad(event){
        const imgHeight = event.detail.height
        if(imgHeight > parseFloat(this.imgadvWxH)){
          this.imgadvWxH = imgHeight+'px'
        }
      }
  
    },
    created() { 
    }
  })
</script>

<style lang='scss'>
 @import "src/styles/mixin";
.tpl33-header{
  position: relative;
  .imgAdv-box{
    .imgAdv_title{
      font-weight: 500;
      font-size: 32px;
      color: #333;
      margin-bottom: 16px;
      .subTitle{
        font-weight: normal;
        font-size: 24px;
        color: #999;
        margin-left: 16px;
      }
    }
    img{
      width: 100%;
    }
  }
}

</style>
